﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities.Presentation;
using System.Activities.Core.Presentation;
using System.ComponentModel.Design;
using System.Windows;
using System.AddIn.Pipeline;
using System.Activities.Statements;

namespace SimpleAddinTest
{
    public class DesignerAddIn : MarshalByRefObject, IDesignerContract
    {

        public WorkflowDesigner designer;
        public DesignSurfaceHost designerHost;

        public DesignerAddIn()
        {
            new DesignerMetadata().Register();
            this.designer = new WorkflowDesigner();
            this.designer.Load(new Sequence());
            this.designerHost = new DesignSurfaceHost(designer);
            MessageBox.Show(AppDomain.CurrentDomain.FriendlyName);
        }

        public System.AddIn.Contract.INativeHandleContract GetDesignView()
        {
            return FrameworkElementAdapters.ViewToContractAdapter(this.designerHost);
        }

        public System.AddIn.Contract.INativeHandleContract GetPropertyGrid()
        {
            return FrameworkElementAdapters.ViewToContractAdapter((FrameworkElement)this.designer.PropertyInspectorView);
        }

        public void Load(string file)
        {
            this.designer.Load(file);
        }

        public void Save(string file)
        {
            this.designer.Save(file);
        }

        public DesignerAddIn GetWFItem()
        {
            return new DesignerAddIn();
        }

        public void SetName(People p) 
        { 
            p.name = "test";
        }

    }

}
